#ifndef SNOW_H
#define SNOW_H

#include <GL/glut.h>
#include<GL/gl.h>

#include<GL/glext.h>
#include <list>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include<GL/glui.h>

#include "flake.h"
#include "launchSite.h"
#include "vector3f.h"
#include "origin.h"

using namespace std;

struct SnowMaterial {
	GLfloat ambient[4];
	GLfloat diffuse[4];
	GLfloat specular[4];
	GLfloat shininess;
	SnowMaterial() {
		ambient[0] = diffuse[0] = specular[0] = 1.0;
		ambient[1] = diffuse[1] = specular[1] = 1.0;
		ambient[2] = diffuse[2] = specular[2] = 1.0;
		ambient[3] = diffuse[3] = specular[3] = 1.0;
		shininess = 64.0;
	}
};
class Snow {
	SnowMaterial snowMaterial;
	int w_width, w_height;

	vector3f anchor, spin, lastspin;

	bool frog; //snow dust

	float rscale, veloc, windc; //constants to scale speed and wind

	vector3f *wind;

	list<flake> snow;
	int num_flakes;

	SiteSet *lsite; //the object
	SiteSet *ground;//the groud

	Origin *origin; //for origin obj model file/.

	void drawflakes();
	void drawaccumulatedsnow();

public:
	Snow(int width, int height, Origin *heightfield);
	virtual ~Snow();
	void setNum_flakes(int n);
	void setWind(int x,int y, int z) {
		wind->setValue(x*windc, y*windc, z*windc);
	}
	void enableFrog(bool t) {
		this->frog = t;
	}
	void initialize(floatbuffer* zbuf);

	void increaseSnow(int n, bool spawn);
	void decreasSnow(int n);

	void reset();
	void init();


	//glut callback functions
	void display();
	void reshape(int width, int height);
	void keyboard(unsigned char key, int x, int y);
	void motion(int x, int y);
	void mouse(int button, int state, int x, int y);

};

#endif
